package com.yanqu.road.server.cmd.chefduel.process2.cross;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.chefduel.ChefDuelProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.chefduel.ChefDuelActivityMgr;
import com.yanqu.road.server.manger.activity.chefduel.ChefDuelMgr;
import com.yanqu.road.server.protocol.Protocol;

/**
 * @Author : Cxp
 * @Time : 2024-11-29
 * @Description : 同步摊主可试吃数量
 */

@Cmd(code = Protocol.S_CROSS_CHEF_DUEL2_SYNC_TASTE_TABLE_CNT, desc = "同步摊主可试吃数量")
public class CrossChefDuel2SyncTasteTableCntCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ChefDuelProto.CrossChefDuel2SyncTasteTableCntMsg reqMsg =
                ChefDuelProto.CrossChefDuel2SyncTasteTableCntMsg.parseFrom(packet.getBytes());

        ChefDuelProto.CrossChefDuel2AutoJoinInfoMsg autoJoinInfo = reqMsg.getAutoJoinInfo();
        int activityId = autoJoinInfo.getGuestActivityId();
        ActivityInfo activityInfo = ChefDuelActivityMgr.getOpenActivityInfo(activityId);
        if (activityInfo == null) {
            return;
        }
        if (packet.getPlayerId() != autoJoinInfo.getGuestId()) {
            return;
        }
        ChefDuelMgr.autoJoinTaste(activityId, reqMsg);
    }

    @Override
    public void sendData(GamePlayer player) {}
}
